package com.example.moblie2021606143cwj0408;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

public class MainActivity2 extends AppCompatActivity {


    private ConstraintLayout edt1;
    private TextView tvMainTitle2;
    private TextView tvmainA;
    private TextView tvMainYaoqiu;
    private TextView tvMainIntA;
    private EditText edtOne;
    private TextView tvMainIntB;
    private EditText edtTwo;
    private Button btnResult;
    private TextView tvFresult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        initView();
        btnResult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = edtOne.getText().toString();
                String string2 = edtTwo.getText().toString();
                int num1=Integer.valueOf(string).intValue();
                int num2=Integer.valueOf(string2).intValue();
                num1=num1+num2;
                string=String.valueOf(num1);
                tvFresult.setText(string);
            }
        });
    }

    private void initView() {
        edt1 = findViewById(R.id.edt_1);
        tvMainTitle2 = findViewById(R.id.tv_main_title2);
        tvmainA = findViewById(R.id.tvmainA);
        tvMainYaoqiu = findViewById(R.id.tv_main_yaoqiu);
        tvMainIntA = findViewById(R.id.tv_main_intA);
        edtOne = findViewById(R.id.edt_one);
        tvMainIntB = findViewById(R.id.tv_main_intB);
        edtTwo = findViewById(R.id.edt_two);
        btnResult = findViewById(R.id.btn_result);
        tvFresult = findViewById(R.id.tv_fresult);
    }
}

